package com.example.yls.demoa;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Point;
import android.os.Build;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by yls on 2019/5/10.
 */

public class MyView extends View {

    private Paint paint = new Paint();

    public MyView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);

        paint.setColor(Color.RED);
        paint.setStrokeWidth(10);
        paint.setAntiAlias(true);
      //  paint.setStyle(Paint.Style.FILL);
        paint.setStyle(Paint.Style.STROKE);
        paint.setTextSize(30);
    }


    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

       /* Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.xu);
        canvas.drawBitmap(bitmap,0,0,paint);
        Matrix matrix = new Matrix();
        matrix.setRotate(90,225,225);
        canvas.drawBitmap(bitmap,matrix,paint);
        matrix.setRotate(180,225,225);
        canvas.drawBitmap(bitmap,matrix,paint);
        matrix.setRotate(270,225,225);
        canvas.drawBitmap(bitmap,matrix,paint);*/

      /*  Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.cat);
       canvas.drawBitmap(bitmap,0,0,paint);
        Matrix matrix = new Matrix();
        matrix.setScale(-1,1);
        matrix.postTranslate(360,0);
        canvas.drawBitmap(bitmap,matrix,paint);

        Matrix matrix1 = new Matrix();
        matrix.setScale(1,-1);
        matrix.postTranslate(0,360);
        canvas.drawBitmap(bitmap,matrix,paint);

        Matrix matrix2 = new Matrix();
        matrix.setScale(-1,-1);
        matrix.postTranslate(360,360);
        canvas.drawBitmap(bitmap,matrix,paint);*/

     //   canvas.drawColor(Color.BLUE);
     //   canvas.drawPoint(100,100,paint);
      //  paint.setColor(Color.BLUE);
      //  paint.setStrokeWidth(5);
      //  paint.setStyle(Paint.Style.STROKE);
      //  canvas.drawLine(100,100,300,500,paint);
       // canvas.drawRect(100,100,300,500,paint);
        //圆角矩形
      //  canvas.drawRoundRect(100,100,300,300,50,50,paint);
       // canvas.drawCircle(200,200,100,paint);
        //圆弧
      //  canvas.drawArc(100,100,400,400,0,90,true,paint);
     canvas.drawText("软件",100,100,paint);
   //五角星
       /* Point a = new Point(0,100);
        Point b = new Point(300,100);
        Point c = new Point(50,250);
        Point d = new Point(250,250);
        Point e = new Point(150,0);
        Path path = new Path();
        path.moveTo(a.x,a.y);
        path.lineTo(b.x,b.y);
        path.lineTo(c.x,c.y);
        path.lineTo(e.x,e.y);
        path.lineTo(d.x,d.y);
        path.lineTo(a.x,a.y);
        canvas.drawPath(path,paint);*/

    }
}
